# 练习2：定义一个类描述平面上的点并提供移动点和计算到另一个点距离的方法。
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    #移动点
    def move(self, x, y):
        self.x = x
        self.y = y

    # 计算距离
    def calc_dist(self, another_point):
        dist_x = self.x - another_point.x if self.x > another_point.x else another_point.x - self.x
        dist_y = self.y - another_point.y if self.y > another_point.y else another_point.y - self.y
        return math.sqrt(dist_x**2 + dist_y**2)
        

if __name__ == '__main__':
    p1 = Point(0, 3)
    p2 = Point(4, 0)
    dist = p1.calc_dist(p2)
    print(f'距离是：{dist}')